import request from '@/config/axios'

export interface StaffVO {
  staffId?: string
  loginName: string
  nickname: string
  remark: string
  deptId?: number
  postIds: number[]
  email: string
  mobile: string
  gender?: number
  avatar?: string
  loginIp?: string
  loginTime?: string
  status: number
  createTime?: string
  deptName?: string
  roles?: any[]
}

export const getStaffSimpleList = async () => {
  return await request.get({ url: '/system/staff/simple-list' })
}

export const getStaffPage = async (params: PageParam) => {
  return await request.get({ url: '/system/staff/page', params })
}

export const getStaff = async (staffId: string) => {
  return await request.get({ url: '/system/staff/get', params: { staffId } })
}

export const createStaff = async (data: StaffVO) => {
  return await request.post({ url: '/system/staff/create', data: data })
}

export const updateStaff = async (data: StaffVO) => {
  return await request.post({ url: '/system/staff/update', data: data })
}

export const deleteStaff = async (staffId: string) => {
  return await request.delete({ url: '/system/staff/delete', params: { staffId } })
}

export const exportStaff = async (params: any) => {
  return await request.download({ url: '/system/staff/export', params })
}

export const getStaffImportTemplate = async () => {
  return await request.download({ url: '/system/staff/get-import-template' })
}

export const updateStaffPasswd = async (staffId: string, password: string) => {
  return await request.post({
    url: '/system/staff/update-passwd',
    data: {
      staffId,
      password
    }
  })
}

export const updateStaffStatus = async (staffId: string, status: number) => {
  return await request.post({
    url: '/system/staff/update-status',
    data: {
      staffId,
      status
    }
  })
}
